package com.stone.daoimpl;
import com.stone.dao.IProviderDao;
import com.stone.dao.hibernatebaseimpl.BaseDaoHibernateImpl;
import com.stone.model.Provider;
import com.stone.utils.Page;

public class ProviderDao extends BaseDaoHibernateImpl<Provider, Long> implements IProviderDao {

	public Page findAllProviders(int pageNo, int pageSize) {
		String queryString = "from Provider provider order by provider.name desc";
		//String queryString = "from Provider provider where provider.displayFlag is null or provider.displayFlag=1 order by provider.name desc";
		return this.findByQueryString4Page(queryString, new Object[]{}, pageNo, pageSize);
	}

	public Page findAllDisplayProviders(int pageNo, int pageSize)
	{
		String queryString = "from Provider provider where provider.displayFlag is null or provider.displayFlag=1 order by provider.name desc";
		return this.findByQueryString4Page(queryString, new Object[]{}, pageNo, pageSize);
	}
	
	public Page findProviderByName(String name, int pageNo, int pageSize) {
		String queryString = "from Provider provider where provider.name like ? order by provider.name desc";
		return this.findByQueryString4Page(queryString, new Object[]{"%"+name+"%"}, pageNo, pageSize);
	}
	
	
}
